#include "stdafx.h"

void CSkinAnimEffect::Init(LPDIRECT3DDEVICE9 _Device)
{
	LPD3DXBUFFER ErrorBuffer;
	D3DXCreateEffectFromFile(_Device,TEXT("skinanimation.es"),NULL,NULL,D3DXSHADER_DEBUG,NULL,&m_Effect,&ErrorBuffer);
	if (ErrorBuffer)
	{
		char* Error = (char*)ErrorBuffer->GetBufferPointer();
		Error = Error;
	}

	m_Anim.OnCreate(_Device,TEXT("tiny.x"));
	m_Anim.SetEffect(m_Effect);
}

void CSkinAnimEffect::Render(CEasyRender* _Render,float _Time)
{
	D3DXMATRIXA16 matWorld,matView,matProj;

	matView = *_Render->GetWorld2ViewMatrix();
	matProj = *_Render->GetProjectorMatrix();
	matWorld = matView * matProj;

	//D3DXMatrixIdentity(&matWorld);
	m_Effect->SetMatrix("matViewProj",&matWorld);

	D3DXMATRIXA16 LocalToWorld;
	//D3DXMatrixIdentity(&LocalToWorld);
	D3DXMatrixTranslation( &LocalToWorld, 0, 30, -100 );
	m_Anim.Render(&LocalToWorld,_Time);
}